﻿<navigation:Page x:Class="LEEAAttendanceControl.Views.ShiftAssignments" 
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
           xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
           xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
           xmlns:my="clr-namespace:LEEAAttendanceControl.Web.Services"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="New Shift Assignments">
    <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <LinearGradientBrush x:Key="BackRectangleBrush" EndPoint=".7,1" StartPoint=".7,0">
                <GradientStop Color="#FCFFFFFF" Offset="0.015"/>
                <GradientStop Color="#F7FFFFFF" Offset="0.375"/>
                <GradientStop Color="#E5FFFFFF" Offset="0.6"/>
                <GradientStop Color="#D1FFFFFF" Offset="1"/>
            </LinearGradientBrush>

            <Style x:Key="DataGridHeaderStyle" TargetType="sdk:DataGridColumnHeader">
                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                <Setter Property="VerticalContentAlignment" Value="Center"/>

                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Grid x:Name="RootGrid">
                                <Rectangle Fill="#FF1F3B53" Stretch="Fill"/>

                                <Rectangle Stretch="Fill" Fill="{StaticResource BackRectangleBrush}" />

                                <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch" Width="1" HorizontalAlignment="Right"/>

                                <CheckBox x:Name="SelectAllCheckBox" Click="SelectAllCheckBox_Click" Margin="2,0,0,0"
                                          VerticalAlignment="Center" HorizontalAlignment="Center"/>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Grid.Resources>
        <ScrollViewer VerticalScrollBarVisibility="Auto">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="270"/>
                    <RowDefinition Height="170"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <Grid Background="#404041" Grid.Row="0">
                    <TextBlock Text="New Shift Assignments" FontSize="14" FontWeight="Bold" Foreground="White"
                               Margin="5,3,3,2" HorizontalAlignment="Left"/>
                </Grid>

                <Grid Margin="10" HorizontalAlignment="Center" Grid.Row="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="10"/>
                        <ColumnDefinition Width="50" />
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="40"/>
                        <ColumnDefinition Width="60"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>

                    <sdk:Label Content="From:" Margin="3,3,0,3" HorizontalAlignment="Left"
                               VerticalAlignment="Center" Grid.ColumnSpan="2" />

                    <sdk:DatePicker x:Name="FromPicker" Grid.Column="2" Width="150" Margin="3"/>

                    <sdk:Label Grid.Column="4" Content="To:" Margin="3" HorizontalAlignment="Left"
                               VerticalAlignment="Center"/>

                    <sdk:DatePicker x:Name="ToPicker" Grid.Column="5" Width="150" Margin="3"/>
                </Grid>

                <StackPanel Orientation="Vertical" Grid.Row="2" Margin="0,0,0,5">
                    <Grid Background="#404041">
                        <TextBlock Text="Employees" Foreground="White" FontSize="13" FontWeight="Bold" Margin="5,2,2,2"
                                   HorizontalAlignment="Left"/>
                    </Grid>

                    <sdk:DataGrid x:Name="EmployeesGrid" AutoGenerateColumns="False" VerticalScrollBarVisibility="Visible"
                                  MaxHeight="240">
                        <sdk:DataGrid.Columns>
                            <sdk:DataGridTemplateColumn Header="ID" CanUserReorder="False" CanUserResize="True" Width="83"
                                                        IsReadOnly="True">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <sdk:Label Content="{Binding ID}" HorizontalAlignment="Left" VerticalAlignment="Center"
                                                   Margin="5,0,0,0" Height="25"/>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Header="First Name" CanUserReorder="False" CanUserResize="True"
                                                        Width="200" IsReadOnly="True">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <sdk:Label Content="{Binding FirstName}" HorizontalAlignment="Left" Margin="5,0,0,0"
                                                   VerticalAlignment="Center"/>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Header="Last Name" CanUserReorder="False" CanUserResize="True"
                                                        Width="200" IsReadOnly="True">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <sdk:Label Content="{Binding LastName}" HorizontalAlignment="Left" Margin="5,0,0,0"
                                                   VerticalAlignment="Center"/>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Header="Department" CanUserReorder="False" CanUserResize="True"
                                                        Width="203" IsReadOnly="True">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <sdk:Label Content="{Binding Department}" HorizontalAlignment="Left" Margin="5,0,0,0"
                                                   VerticalAlignment="Center"/>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Width="80" HeaderStyle="{StaticResource DataGridHeaderStyle}"
                                                        CanUserReorder="False" CanUserResize="False">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <CheckBox x:Name="EmployeeCheck" IsChecked="{Binding IsChecked, Mode=TwoWay}"
                                                  HorizontalAlignment="Center" VerticalAlignment="Center"
                                                  Click="EmployeeCheck_Click"/>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                        </sdk:DataGrid.Columns>
                    </sdk:DataGrid>
                </StackPanel>

                <StackPanel Grid.Row="3" Margin="0,10,0,0">
                    <Grid Background="#404041">
                        <TextBlock Text="Shifts" Foreground="White" FontSize="13" FontWeight="Bold" Margin="5,2,2,2"
                                   HorizontalAlignment="Left"/>
                    </Grid>

                    <riaControls:DomainDataSource x:Name="ShiftsDataSource" AutoLoad="True" QueryName="GetShiftsByCompanyID"
                                                  LoadingData="DomainDataSource_LoadingData">
                        <riaControls:DomainDataSource.DomainContext>
                            <my:LEEAContext/>
                        </riaControls:DomainDataSource.DomainContext>
                    </riaControls:DomainDataSource>

                    <sdk:DataGrid x:Name="ShiftsGrid" AutoGenerateColumns="False" MaxHeight="155"
                                  ItemsSource="{Binding Data, ElementName=ShiftsDataSource}">
                        <sdk:DataGrid.Columns>
                            <sdk:DataGridTemplateColumn Header="Shift" Width="118" CanUserReorder="False"
                                                            CanUserResize="False" IsReadOnly="True">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Grid Margin="0" Background="{Binding Color}">
                                            <sdk:Label Content="{Binding ShiftName}" VerticalAlignment="Center" Height="25"
                                                       HorizontalAlignment="Left" Margin="5,0,0,0"
                                                       Foreground="{Binding ForeColor}"/>
                                        </Grid>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Width="95" CanUserReorder="False" CanUserResize="False">
                                <sdk:DataGridTemplateColumn.HeaderStyle>
                                    <Style TargetType="sdk:DataGridColumnHeader">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate>
                                                    <Grid>
                                                        <Rectangle Fill="#FF1F3B53" Stretch="Fill"/>

                                                        <Rectangle Stretch="Fill" Fill="{StaticResource BackRectangleBrush}"/>

                                                        <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch"
                                                                   Width="1" HorizontalAlignment="Right"/>

                                                        <TextBlock Text="Saturday" HorizontalAlignment="Center"
                                                                   VerticalAlignment="Center"/>
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </sdk:DataGridTemplateColumn.HeaderStyle>
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Grid Margin="0" Background="{Binding Color}">
                                            <CheckBox x:Name="SaturdayBox" VerticalAlignment="Center"
                                                      HorizontalAlignment="Center" Click="SaturdayBox_Click"/>
                                        </Grid>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Width="95" CanUserReorder="False" CanUserResize="False">
                                <sdk:DataGridTemplateColumn.HeaderStyle>
                                    <Style TargetType="sdk:DataGridColumnHeader">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate>
                                                    <Grid>
                                                        <Rectangle Fill="#FF1F3B53" Stretch="Fill"/>

                                                        <Rectangle Stretch="Fill" Fill="{StaticResource BackRectangleBrush}"/>

                                                        <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch"
                                                                   Width="1" HorizontalAlignment="Right"/>

                                                        <TextBlock Text="Sunday" HorizontalAlignment="Center"
                                                                   VerticalAlignment="Center"/>
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </sdk:DataGridTemplateColumn.HeaderStyle>
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Grid Margin="0" Background="{Binding Color}">
                                            <CheckBox x:Name="SundayBox" VerticalAlignment="Center"
                                                      HorizontalAlignment="Center" Click="SundayBox_Click"/>
                                        </Grid>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Width="95" CanUserReorder="False" CanUserResize="False">
                                <sdk:DataGridTemplateColumn.HeaderStyle>
                                    <Style TargetType="sdk:DataGridColumnHeader">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate>
                                                    <Grid>
                                                        <Rectangle Fill="#FF1F3B53" Stretch="Fill"/>

                                                        <Rectangle Stretch="Fill" Fill="{StaticResource BackRectangleBrush}"/>

                                                        <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch"
                                                                   Width="1" HorizontalAlignment="Right"/>

                                                        <TextBlock Text="Monday" HorizontalAlignment="Center"
                                                                   VerticalAlignment="Center"/>
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </sdk:DataGridTemplateColumn.HeaderStyle>
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Grid Margin="0" Background="{Binding Color}">
                                            <CheckBox x:Name="MondayBox" VerticalAlignment="Center"
                                                      HorizontalAlignment="Center" Click="MondayBox_Click"/>
                                        </Grid>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Width="95" CanUserReorder="False" CanUserResize="False">
                                <sdk:DataGridTemplateColumn.HeaderStyle>
                                    <Style TargetType="sdk:DataGridColumnHeader">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate>
                                                    <Grid>
                                                        <Rectangle Fill="#FF1F3B53" Stretch="Fill"/>

                                                        <Rectangle Stretch="Fill" Fill="{StaticResource BackRectangleBrush}"/>

                                                        <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch"
                                                                   Width="1" HorizontalAlignment="Right"/>

                                                        <TextBlock Text="Tuesday" HorizontalAlignment="Center"
                                                                   VerticalAlignment="Center"/>
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </sdk:DataGridTemplateColumn.HeaderStyle>
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Grid Margin="0" Background="{Binding Color}">
                                            <CheckBox x:Name="TuesdayBox" VerticalAlignment="Center"
                                                      HorizontalAlignment="Center" Click="TuesdayBox_Click"/>
                                        </Grid>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Width="95" CanUserReorder="False" CanUserResize="False">
                                <sdk:DataGridTemplateColumn.HeaderStyle>
                                    <Style TargetType="sdk:DataGridColumnHeader">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate>
                                                    <Grid>
                                                        <Rectangle Fill="#FF1F3B53" Stretch="Fill"/>

                                                        <Rectangle Stretch="Fill" Fill="{StaticResource BackRectangleBrush}"/>

                                                        <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch"
                                                                   Width="1" HorizontalAlignment="Right"/>

                                                        <TextBlock Text="Wednesday" HorizontalAlignment="Center"
                                                                   VerticalAlignment="Center"/>
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </sdk:DataGridTemplateColumn.HeaderStyle>
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Grid Margin="0" Background="{Binding Color}">
                                            <CheckBox x:Name="WednesdayBox" VerticalAlignment="Center"
                                                      HorizontalAlignment="Center" Click="WednesdayBox_Click"/>
                                        </Grid>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Width="95" CanUserReorder="False" CanUserResize="False">
                                <sdk:DataGridTemplateColumn.HeaderStyle>
                                    <Style TargetType="sdk:DataGridColumnHeader">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate>
                                                    <Grid>
                                                        <Rectangle Fill="#FF1F3B53" Stretch="Fill"/>

                                                        <Rectangle Stretch="Fill" Fill="{StaticResource BackRectangleBrush}"/>

                                                        <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch"
                                                                   Width="1" HorizontalAlignment="Right"/>

                                                        <TextBlock Text="Thursday" HorizontalAlignment="Center"
                                                                   VerticalAlignment="Center"/>
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </sdk:DataGridTemplateColumn.HeaderStyle>
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Grid Margin="0" Background="{Binding Color}">
                                            <CheckBox x:Name="ThursdayBox" VerticalAlignment="Center"
                                                  HorizontalAlignment="Center" Click="ThursdayBox_Click"/>
                                        </Grid>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn Width="95" CanUserReorder="False" CanUserResize="False">
                                <sdk:DataGridTemplateColumn.HeaderStyle>
                                    <Style TargetType="sdk:DataGridColumnHeader">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate>
                                                    <Grid>
                                                        <Rectangle Fill="#FF1F3B53" Stretch="Fill"/>

                                                        <Rectangle Stretch="Fill" Fill="{StaticResource BackRectangleBrush}"/>

                                                        <Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch"
                                                                   Width="1" HorizontalAlignment="Right"/>

                                                        <TextBlock Text="Friday" HorizontalAlignment="Center"
                                                                   VerticalAlignment="Center"/>
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </sdk:DataGridTemplateColumn.HeaderStyle>
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Grid Margin="0" Background="{Binding Color}">
                                            <CheckBox x:Name="FridayBox" VerticalAlignment="Center"
                                                      HorizontalAlignment="Center" Click="FridayBox_Click"/>
                                        </Grid>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                        </sdk:DataGrid.Columns>
                    </sdk:DataGrid>
                </StackPanel>

                <Grid Grid.Row="4">
                    <Button x:Name="ApplyButton" Content="Apply" Width="60" Height="25" HorizontalAlignment="Center"
                            Margin="0,25,0,0" Click="ApplyButton_Click"/>
                </Grid>
            </Grid>
        </ScrollViewer>
    </Grid>
</navigation:Page>
